<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
		<meta charset="utf-8" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">学校组织结构</a></li>
    <li><a href="#">学校信息</a></li>
    </ul>
    </div>
    <div class="formbody">
    <div class="formtitle"><span>基本信息</span></div>
    <ul class="forminfo">
    <c:if test="${ userRole <=2 }">
    <li><label>学校名称</label><input name="schoolName" id="schoolName" type="text" class="dfinput"  value="${school.schoolName }"/></li>
     <li><label>学校地址</label><input name="schoolAddress" id="schoolAddress" type="text" class="dfinput"  value="${school.schoolAddress }"/></li>
      <li><label>学校电话</label><input name="schoolPhone" id="schoolPhone" type="text" class="dfinput"  value="${school.schoolPhone }"/></li>
     <li><label>学校网址</label><input name="schoolWeb" id="schoolWeb" type="text" class="dfinput"  value="${school.schoolWeb }"/></li>
    <li><label>学校简介</label><textarea class="textinput" id="schoolIntroduzione"  name="schoolIntroduzione">${school.schoolIntroduzione }</textarea></li>
    <li><label>学校负责人</label><input name="schoolPerson" id="schoolPerson" type="text" class="dfinput"  value="${school.schoolPerson }"/></li>
    <li><label>负责人职位</label><input name="schoolPersonCharge" id="schoolPersonCharge" type="text" class="dfinput"  value="${school.schoolPersonCharge }"/></li>
    <li><label>负责人电话</label><input name="schoolPersonPhone" id="schoolPersonPhone" type="text" class="dfinput"  value="${school.schoolPersonPhone }"/></li>
    <input value="${school.id }" type="hidden" name="id" id="id">
    	<li><label>&nbsp;</label><input name="" id="" type="button"  onclick="saveBase();"   class="btn" value="确认保存"/></li>
    
    </c:if>
    <c:if test="${ userRole >2 }"><li><label>学校名称</label><input name="" type="text" class="dfinput"  value="${school.schoolName }" readonly="readonly"/></li>
     <li><label>学校地址</label><input name="" type="text" class="dfinput"  value="${school.schoolAddress }"readonly="readonly"/></li>
      <li><label>学校电话</label><input name="" type="text" class="dfinput"  value="${school.schoolPhone }"readonly="readonly"/></li>
     <li><label>学校网址</label><input name="" type="text" class="dfinput"  value="${school.schoolWeb }"readonly="readonly"/></li>
    <li><label>学校简介</label><textarea class="textinput" readonly="readonly" >${school.schoolIntroduzione }</textarea></li>
    <li><label>学校负责人</label><input name="" type="text" class="dfinput"  value="${school.schoolPerson }"readonly="readonly"/></li>
    <li><label>负责人职位</label><input name="" type="text" class="dfinput"  value="${school.schoolPersonCharge }"readonly="readonly"/></li>
    <li><label>负责人电话</label><input name="" type="text" class="dfinput"  value="${school.schoolPersonPhone }"readonly="readonly"/></li>
	</c:if>
    </ul>
    </div>
</body>

<script src="js/jquery-1.7.2.js"></script>
<script type="text/javascript" src="js/jquery.tips.js"></script>
<script src="layer/layer.js"></script>
<script>
	/* $(".btn").click(
		function  () {
			layer.msg('更新成功！');
			
			
		}
	) */
	function saveBase() {
			if($("#schoolName").val()==''){
				$("#schoolName").tips({
					side : 1,
					msg : '	请输入学校名称',
					bg : '#0099FF',
					time : 3
				});
				return false;
			}
			if($("#schoolAddress").val()==''){
				$("#schoolAddress").tips({
					side : 1,
					msg : '	请输入学校地址',
					bg : '#0099FF',
					time : 3
				});
				return false;
			}
			if($("#schoolPhone").val()==''){
				$("#schoolPhone").tips({
					side : 1,
					msg : '	请输入学校电话',
					bg : '#0099FF',
					time : 3
				});
				return false;
			}
			if($("#schoolWeb").val()==''){
				$("#schoolWeb").tips({
					side : 1,
					msg : '	请输入学校网址',
					bg : '#0099FF',
					time : 3
				});
				return false;
			}
			if($("#schoolIntroduzione").val()==''){
				$("#schoolIntroduzione").tips({
					side : 1,
					msg : '	请输入学校介绍',
					bg : '#0099FF',
					time : 3
				});
				return false;
			}
			if($("#schoolPerson").val()==''){
				$("#schoolPerson").tips({
					side : 1,
					msg : '	请输入学校负责人',
					bg : '#0099FF',
					time : 3
				});
				return false;
			}
			
			if($("#schoolPersonPhone").val()==''){
				$("#schoolPersonPhone").tips({
					side : 1,
					msg : '	请输入学校负责人电话',
					bg : '#0099FF',
					time : 3
				});
				return false;
			}
			if($("#schoolPersonCharge").val()==''){
				$("#schoolPersonCharge").tips({
					side : 1,
					msg : '	请输入学校负责人职务',
					bg : '#0099FF',
					time : 3
				});
				return false;
			}
			$.ajax({
				type: "POST",
				url: "admin/school_edit.do",
				data: { id : $("input[name='id']").val(),schoolName : $("input[name='schoolName']").val(),schoolAddress : $("input[name='schoolAddress']").val(),schoolPhone:$("input[name='schoolPhone']").val(),schoolWeb:$("input[name='schoolWeb']").val(),schoolIntroduzione:$("textarea[name='schoolIntroduzione']").val(),schoolPerson : $("input[name='schoolPerson']").val(),schoolPersonPhone:$("input[name='schoolPersonPhone']").val(),schoolPersonCharge:$("input[name='schoolPersonCharge']").val()},
				async: true,
				dataType: "json",
				success: function(data) {
					if("success" == data.result){
						layer.alert('修改成功!', {
				            skin: 'layer-ext-moon' 
						}, function(){
							location.reload();
						 });
						
				}else {
					layer.alert('修改失败!', {
			            skin: 'layer-ext-moon' 
			        });
					}
					}
				})
		}
</script>
</html>

